<!DOCTYPE html>
<html">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            flex-direction: column;
            gap: 30px;
            background: rgb(34, 32, 32);
        }

        .inputBox {
            position: relative;
            width: 250px;
        }

        .inputBox input {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid rgba(255, 255, 255, 0.25);
            background: rgb(34, 32, 32);
            border-radius: 5px;
            outline: none;
            color: #fff;
            font-size: 1em;
            transition: 0.5s;
        }

        .inputBox span {
            position: absolute;
            left: 0;
            padding: 10px;
            pointer-events: none;
            font-size: 1em;
            color: rgba(255, 255, 255, 0.25);
            text-transform: uppercase;
            transition: 0.5s;
        }

        .inputBox input:valid ~ span,
        .inputBox input:focus ~ span {
            color: aqua;
            transform: translateX(10px) translateY(-7px);
            font-size: 0.65em;
            padding: 0 10px;
            background: rgb(34, 32, 32);
            border-left: 1px solid aqua;
            border-right: 1px solid aqua;
            letter-spacing: 0.2em;
        }

        .inputBox:nth-child(2) input:valid ~ span,
        .inputBox:nth-child(2) input:focus ~ span {
            background: red;
            color: rgb(34, 32, 32);
            border-radius: 2px;
        }

        .inputBox input:valid,
        .inputBox input:focus {
            border: 1px solid aqua;
        }
    </style>
</head>
<body>
    <div class="inputBox">
        <input type="text" required="required" />
        <span>包包包呀1112321232131</span>
    </div>
    <div class="inputBox">
        <input type="text" required="required" />
        <span>2222</span>
    </div>
</body>
</html>